// 1464. 数组中两元素的最大乘积
// 思路：一次遍历，维护最大数和此大数

#include <vector>
using namespace std;

class Solution
{
public:
    int maxProduct(vector<int>& nums)
    {
        int firstMax = 0, secondMax = 0;
        for(int i = 0; i < nums.size(); i++)
        {
            if(nums[i] > firstMax)
            {
                secondMax = firstMax;
                firstMax = nums[i];
            }
            else if(nums[i] > secondMax) secondMax = nums[i];
        }

        return (firstMax - 1) * (secondMax - 1);
    }
};